<?php 

date_default_timezone_set("America/El_Salvador");
function Saber_IP(){
        if(getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown")){
                 $ip = getenv("HTTP_CLIENT_IP");
        }
           elseif(getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown")){
               $ip = getenv("HTTP_X_FORWARDED_FOR");
           }
           elseif(getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown")){
               $ip = getenv("REMOTE_ADDR");
           }
           elseif(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown")){
 
               $ip = $_SERVER['REMOTE_ADDR'];
           }
           else {
               $ip = "Unknown";
           }
          return $ip;
    }
 
//La forma para usarse es asi:
 /*
$IP = Saber_Ip();
 
echo "Tu IP es: ".$IP; */

function fechaActual(){

	switch (date("l")){
		case "Monday":
			$dia = "Lunes";
			break;
		case "Tuesday":
			$dia = "Martes";
			break;
		case "Wednesday":
			$dia = "Miercoles";
			break;
		case "Thursday":
			$dia = "Jueves";
			break;
		case "Friday":
			$dia = "Viernes";
			break;
		case "Saturday":
			$dia = "Sabado";
			break;
		case "Sunday":
			$dia = "Domingo";
			break;
	}
	
	switch(date("F")){
		case "January":
			$mes = "Enero";
			break;
			
					case "February":
			$mes = "Febrero";
			break;
			
					case "March":
			$mes = "Marzo";
			break;
			
					case "April":
			$mes = "Abril";
			break;
			
					case "May":
			$mes = "Mayo";
			break;
			
					case "June":
			$mes = "Junio";
			break;
			
					case "July":
			$mes = "Julio";
			break;
			
					case "August":
			$mes = "Agosto";
			break;
			
					case "September":
			$mes = "Septiembre";
			break;
			
					case "October":
			$mes = "Octubre";
			break;
			
					case "November":
			$mes = "November";
			break;
			
					case "December":
			$mes = "Diciembre";
			break;
			
	}

	/*echo "Hoy es ".$dia.", ".date("j")." de ".$mes." de ".date("Y");*/
	$dateActual = $dia .", ".date("j")." de ".$mes." de ".date("Y");
	return $dateActual;
}
	function quitar_espa($cadena_con_espacios){
		$cadena_sin_espacios = str_replace(' ', '_', $cadena_con_espacios);
		return 	$cadena_sin_espacios;
	}


	$fechaUsuario = fechaActual();
	//echo $fecha;
	$userAgent = $_SERVER['HTTP_USER_AGENT'];
	 $ipUsuario = Saber_Ip();
	 
?>
